package com.example.demo.chacheable;

import java.util.concurrent.TimeUnit;

public enum MyTimeUnit {
    MS(TimeUnit.MILLISECONDS,"MS"),SS(TimeUnit.SECONDS,"SS"),MM(TimeUnit.MINUTES,"MM"),HH(TimeUnit.HOURS,"HH"),DD(TimeUnit.DAYS,"DD");
    private TimeUnit timeUnit;
    private String unit;
    MyTimeUnit(TimeUnit timeUnit, String unit) {
        this.timeUnit = timeUnit;
        this.unit =unit.toUpperCase();
    }
    public static TimeUnit getTimeUnit(String unit){
        switch (unit.toUpperCase()){
            case "MS":
                return TimeUnit.MILLISECONDS;
            case "SS":
                return TimeUnit.SECONDS;
            case "MM":
                return TimeUnit.MINUTES;
            case "HH":
                return TimeUnit.HOURS;
            case "DD":
                return TimeUnit.DAYS;
            default:
                return TimeUnit.MILLISECONDS;
        }
    }
}
